package GameControl;

import java.awt.Frame;
import net.percederberg.tetris.Game;

/**
 *
 * @author hell
 */
public class GameControl {
    
    public static ChatFrame chatframe = new ChatFrame(); // Frame for holding chat contols
    public static Frame gameFrame = new Frame("Tetris");
    public static Game game = new Game();
    
    /**
     * Returns current game state.
     * @return state of the game
     */
    public static GameState getState() {
        return game.state;
    }
    /**
     * Sets current game state.
     * @param state a game state
     */
    public static void setState(GameState state) {
        game.state = state;
        game.handleStart();
        game.getComponent().requestFocus();
    }
    
    /**
     * Performs single game command. <code>Code</code>s sequence should be used
     * to generate pseudo random numbers.
     * @param code varies from 0 to 3 inclusive
     */
    public static void GameCommand(int code){
        if(code == 0){
            game.pMoveLeft();
        }
        if(code == 1){
            game.pMoveRight();
        }
        if(code == 2){
            game.pStepDown();
        }
        if(code == 3){
            game.pRotateCounterClockwise();
        }
    }
    /**
     * Causes figure to move down step by step.
     */
    public static void GameStepdown(){}
    /**
     * Adds message to the chat board.
     * @param message a message to be shown
     */
    public static void ChatMessage(String message){ // What about some id of sender?
        // Need to access created ChatFrame here
        chatframe.AddMessage(message);
    }
}
